/************************************************************************ * * * File: arraystack.h * * * * Author: Robb T. Koether * * * * Date: Mar 22, 1999 * * * * Abstract: This file contains the ArrayStack template class * * definition and implementation * * * ************************************************************************/ #ifndef ARRAYSTACK_H #define ARRAYSTACK_H // Header files #include #include #include "arraylist.h" using namespace std; /************************************************************************ * * * The ArrayStack class definition * * * ************************************************************************/ template class ArrayStack : private ArrayList { // Public member functions public: // Constructors ArrayStack() {} ArrayStack(const ArrayStack& stk) : ArrayList(stk) {} // Inspectors T Top() const {return GetElement(Size());} int Size() const {return ArrayList::Size();} bool Empty() const {return ArrayList::Empty();} // Mutators void Push(const T& value) {PushBack(value);} T Pop() {return PopBack();} void MakeEmpty() {ArrayList::MakeEmpty();} // Facilitators void Input(istream& in) {ArrayList::Input(in);} void Output(ostream& out) const {ArrayList::Output(out);} // Other member functions void Validate() const {ArrayList::Validate();} }; // Operators template istream& operator>>(istream&, ArrayStack&); template ostream& operator<<(ostream&, const ArrayStack&); /************************************************************************ * * * Function: operator>> * * * * Purpose: To extract an ArrayStack from the input stream * * * ************************************************************************/ template istream& operator>>(istream& in, ArrayStack& stk) { stk.Input(in); return in; } /************************************************************************ * * * Function: operator<< * * * * Purpose: To insert an ArrayStack into the output stream * * * ************************************************************************/ template ostream& operator<<(ostream& out, const ArrayStack& stk) { stk.Output(out); return out; } #endif